package com.ytxg.util;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class JsoupUtils {
    public static void main(String[] args) throws IOException {


        Document document = Jsoup.connect("https://yt-xg.github.io/").get();
        Element body = document.body();
        String html = body.html();
        String s = removeEleProp(html);

        System.out.println();


    }


    private static final String regEx_tag = "<(\\w[^>|\\s]*)[\\s\\S]*?>";

    public static String removeEleProp(String htmlStr) {
        Pattern p = Pattern.compile(regEx_tag, Pattern.CASE_INSENSITIVE);
        Matcher m = p.matcher(htmlStr);
        StringBuffer sb = new StringBuffer();
        while (m.find()) {
            String tag = m.group(1);
            m.appendReplacement(sb, "<" + tag + ">");
        }
        m.appendTail(sb);
        return sb.toString();
    }
}
